//
//  SHTabBarViewController.m
//  读读日报
//
//  Created by Shawn on 16/3/3.
//  Copyright © 2016年 Shawn. All rights reserved.
//

#import "SHTabBarViewController.h"
#import "SHStartPageViewController.h"

#import "SHDiscoverVc.h"
#import "SHHomePageTc.h"
#import "SHMessageVc.h" 
#import "SHPersonalDataVc.h"

#import "SHNavController.h"

@interface SHTabBarViewController ()



@end

@implementation SHTabBarViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
   
    [self setUpAllController];
    
    [self.tabBar setFrame:CGRectMake(0, 625, 375, 44)];
    

    
}

//添加所有子控制器
-(void)setUpAllController
{
    //添加首页controller
    SHHomePageTc * homePage =[[SHHomePageTc alloc]init];
    homePage.view.backgroundColor = [UIColor orangeColor];
    [self addChildViewController:homePage];
    [self setChildViewController:homePage andImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Feed_Normal"] andSelectedImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Feed_Highlight"]andTitle:@"首页"];
    

    //添加发现controller
    SHDiscoverVc * discover = [[SHDiscoverVc alloc]init];
    discover.view.backgroundColor =[UIColor redColor];
    [self addChildViewController:discover];
      [self setChildViewController:discover andImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Explore_Normal"] andSelectedImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Explore_Highlight"]andTitle:nil];
    

    
    //添加消息controller
    SHMessageVc * message = [[SHMessageVc alloc]init];
    message.view.backgroundColor = [UIColor yellowColor];
    [self setChildViewController:message andImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Notification_Normal"] andSelectedImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Notification_Highlight"]andTitle:@"消息"];
    
  
    
    
    //添加个人资料controller
    SHPersonalDataVc * personal = [[SHPersonalDataVc alloc]init];
    personal.view.backgroundColor = [UIColor grayColor];
    [self setChildViewController:personal andImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Profile_Normal"] andSelectedImage:[UIImage imageNamed:@"HMRV3_TabBarIcon_Profile_Highlight"] andTitle:@"个人资料"];
    
    
}

//取消图片渲染


-(void)setChildViewController:(UIViewController *)vc andImage:(UIImage *)image andSelectedImage:(UIImage *)selectedImage andTitle:(NSString *)title
{
    [self addChildViewController:vc];
    
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.image = image;
    vc.tabBarItem.selectedImage = selectedImage;
    
    //创建一个导航控制器
    SHNavController * nav = [[SHNavController alloc]initWithRootViewController:vc];
    
    vc.navigationItem.title = title;

    [self addChildViewController:nav];
}

@end
